"use strict";
cc._RF.push(module, 'a2fcdSbdnxH66vFmGOBFenN', 'YaoshuiMgr');
// scripts/YaoshuiMgr.js

"use strict";

var e = require;
var t = module;
var n = exports;
Object.defineProperty(n, "__esModule", {
  value: !0
});

var o = e("VideoHint"),
    i = cc._decorator,
    a = i.ccclass,
    r = i.property,
    s = function (e) {
  __extends(t, e);

  function t() {
    var t = null !== e && e.apply(this, arguments) || this;
    t.redYaoshui = null;
    t.greenYaoshui = null;
    t.redTimer = null;
    t.greenTimer = null;
    return t;
  }

  n = t;

  t.prototype.onLoad = function () {
    n.Instance = this;
    cc.sys.localStorage.getItem("RedYao") || cc.sys.localStorage.setItem("RedYao", "false");
    cc.sys.localStorage.getItem("GreenYao") || cc.sys.localStorage.setItem("GreenYao", "false");
  };

  t.prototype.start = function () {};

  t.prototype.ShowYaoshui = function () {
    if (SDK.Mgr.Inst.hasAds) {
      var e = this;

      if (0 == n.RedYao) {
        e.redTimer = function () {
          e.redYaoshui.active = !0;
          e.redYaoshui.stopAllActions();
          e.redYaoshui.setPosition(cc.v2(-800, 650));
          var t = cc.scaleTo(.1, 1.4).easing(cc.easeSineInOut()),
              n = cc.scaleTo(.1, 1.2).easing(cc.easeSineInOut()),
              o = cc.delayTime(.15),
              i = cc.scaleTo(.1, 1.4).easing(cc.easeSineInOut()),
              a = cc.scaleTo(.1, 1.2).easing(cc.easeSineInOut()),
              r = cc.delayTime(.8),
              s = cc.repeatForever(cc.sequence(t, n, o, i, a, r));
          e.redYaoshui.runAction(s);
          SDK.Mgr.Inst.event("ShowRedDrink");
        };

        e.scheduleOnce(e.redTimer, 7 * Math.random() + 3);
      } else if (0 == n.GreenYao) {
        e.greenTimer = function () {
          e.greenYaoshui.active = !0;
          e.greenYaoshui.stopAllActions();
          e.greenYaoshui.setPosition(cc.v2(-800, 650));
          var t = cc.scaleTo(.1, 1.4).easing(cc.easeSineInOut()),
              n = cc.scaleTo(.1, 1.2).easing(cc.easeSineInOut()),
              o = cc.delayTime(.15),
              i = cc.scaleTo(.1, 1.4).easing(cc.easeSineInOut()),
              a = cc.scaleTo(.1, 1.2).easing(cc.easeSineInOut()),
              r = cc.delayTime(.8),
              s = cc.repeatForever(cc.sequence(t, n, o, i, a, r));
          e.greenYaoshui.runAction(s);
          SDK.Mgr.Inst.event("ShowGreenDrink");
        };

        e.scheduleOnce(e.greenTimer, 7 * Math.random() + 3);
      }
    }
  };

  t.prototype.RedYaoClick = function () {
    this.Hide();
    var e = "RedDrink_Ad";
    SDK.Mgr.Inst.event(e + "Click");

    var t = function t(i) {
      if (i == SDK.Define.AdsCode.finish) {
        SDK.Mgr.Inst.event(e + "Success");

        if (null != KingController.Instance) {
          KingController.Instance.DrinkRedWine();
          n.RedYao = !0;
          SDK.ToastMgr.Inst.showToast("获得长生药水");
        }
      } else if (i == SDK.Define.AdsCode.cancel) {
        SDK.Mgr.Inst.event(e + "Cancel");
        o["default"].Instance.openPanel(t);
      } else {
        SDK.ToastMgr.Inst.showToast("暂无广告，请稍后再试");
        SDK.Mgr.Inst.event(e + "NoAd");
      }
    };

    SDK.Mgr.Inst.showVideo(t);
  };

  t.prototype.GreenYaoClick = function () {
    this.Hide();
    var e = "GreenDrink_Ad";
    SDK.Mgr.Inst.event(e + "Click");

    var t = function t(i) {
      if (i == SDK.Define.AdsCode.finish) {
        SDK.Mgr.Inst.event(e + "Success");

        if (null != KingController.Instance) {
          KingController.Instance.DrinkGreenWine();
          n.GreenYao = !0;
        }
      } else if (i == SDK.Define.AdsCode.cancel) {
        SDK.Mgr.Inst.event(e + "Cancel");
        o["default"].Instance.openPanel(t);
      } else {
        SDK.ToastMgr.Inst.showToast("暂无广告，请稍后再试");
        SDK.Mgr.Inst.event(e + "NoAd");
      }
    };

    SDK.Mgr.Inst.showVideo(t);
  };

  t.prototype.Hide = function () {
    this.unschedule(this.redTimer);
    this.unschedule(this.greenTimer);
    this.redYaoshui.stopAllActions();
    this.greenYaoshui.stopAllActions();
    this.redYaoshui.active = !1;
    this.greenYaoshui.active = !1;
  };

  var n;
  t.RedYao = !1;
  t.GreenYao = !1;
  t.Instance = null;

  __decorate([r(cc.Node)], t.prototype, "redYaoshui", void 0);

  __decorate([r(cc.Node)], t.prototype, "greenYaoshui", void 0);

  return n = __decorate([a], t);
}(cc.Component);

n["default"] = s;

cc._RF.pop();